package com.pos43.business.service.impl;

import java.util.List;

import com.pos43.business.dao.IProductDao;
import com.pos43.business.dao.IProductTypeDao;
import com.pos43.business.dao.impl.ProductDao;
import com.pos43.business.dao.impl.ProductTypeDao;
import com.pos43.business.service.IProductService;
import com.pos43.domain.Product;
import com.pos43.domain.ProductType;

public class ProductService implements IProductService{

	IProductTypeDao productTypeDao = new ProductTypeDao();
	IProductDao productDao = new ProductDao();
	
	public Integer addProduct(String pname, Float price, ProductType productType){
		Product productInstance = new Product();
		productInstance.setPname(pname);
		productInstance.setPrice(price);
		productInstance.setProductType(productType);
		productInstance.setOnSale(true);
		return productDao.save(productInstance);
	}
	
	public void delProduct(Integer id){
		productDao.delete(id);
	}
	
	public void delProduct(Product product){
		productDao.delete(product);
	}
	
	public void updateProduct(Product product){
		productDao.update(product);
	}
	
	public List<Product> listProduct(){
		return productDao.findAll();
	}
	
	public Product getProduct(Integer id){
		return productDao.get(id);
	}
	
	public List<Product> findProduct(String key) {
		return productDao.findByParam(key);
	}
	
	
	public IProductTypeDao getProductTypeDao() {
		return productTypeDao;
	}

	public void setProductTypeDao(IProductTypeDao productTypeDao) {
		this.productTypeDao = productTypeDao;
	}

	public void setTeacherDao(IProductTypeDao  productTypeDao) {
		this.productTypeDao = productTypeDao;
	}

	public IProductDao getProductDao() {
		return productDao;
	}

	public void setProductDao(IProductDao productDao) {
		this.productDao = productDao;
	}

}
